var balance;
var amount;
var status;
var id;
var name;
var phone;
var carid;
$(function(){
    $.ajax({
        url : "/parking/selectbyphone",
        type : "get",
        data : {
            "userPhone" : "13124156345"
        },
        success : function(data) {
            balance=data.userBalance;
            amount=data.userAmount;
            status=data.userStatus;
            id=data.userId;
            name=data.username;
            phone=data.userPhone;
            carid=data.userCarId;
            $("#customerID").val(id);
        }
    });


    $("#updateInfoBtn").click(function(){
        var customerRealName=$("#customerRealName").val();
        var customerPhone=$("#customerPhone").val();
        var customerPlate=$("#customerPlate").val();
        if(customerRealName==""){
            customerRealName=name;
        }
        if(customerPhone==""){
            customerPhone=phone;
        }
        if(customerPlate==""){
            customerPlate=carid;
        }
        $.ajax({
            url : "/parking/userUpd",
            type : "get",
            dataType: "json",
            data : {
                "userId" : $("#customerID").val(),
                "userName" : customerRealName,
                "userPhone" : customerPhone,
                "userCarId" : customerPlate,
                "userBalance": balance,
                "userAmount": amount,
                "userStatus": status
            },
            success : function(data) {
                if(data.updResult == "true"){
                    alert("修改成功");
                    window.location.href="http://localhost:9000/info_edit.html";

                }else{
                    alert("修改失败");
                    window.location.href="http://localhost:9000/info_edit.html";

                }
            }
        });

    });

    $("#backInfoBtn").click(function(){
        window.location.href="http://localhost:9000/pwd_update.html";
        window.event.returnValue=false;
    })

})
